Skip to content

security(scrypt): Force Scrypt parameters to have all n, p, r values#4680

Merged
sergei-boiko-trustwallet merged 9 commits intomasterfrom
fix/scrypt-deserialize
Mar 6, 2026
Merged

security(scrypt): Force Scrypt parameters to have all n, p, r values#4680
sergei-boiko-trustwallet merged 9 commits intomasterfrom
fix/scrypt-deserialize

Conversation

@sergei-boiko-trustwallet
Copy link
Copy Markdown
Contributor

This pull request updates the construction logic for ScryptParameters to improve validation and error handling when parsing JSON input. Now, the constructor checks for the presence of all required scrypt parameters and validates them, throwing clear exceptions if any are missing or invalid.

Improvements to input validation and error handling:

  • Updated the ScryptParameters constructor in src/Keystore/ScryptParameters.cpp to:
    • Require the presence of all three scrypt parameters (n, p, and r) in the input JSON, throwing an exception if any are missing.
    • Immediately validate the parameters after parsing and throw a detailed exception if validation fails.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to harden keystore scrypt parameter parsing by requiring n, p, and r to be present in JSON input and validating the parameters early to fail fast on malformed keystore files.

Changes:

  • Added a presence check for required scrypt parameters (n, p, r) when constructing ScryptParameters from JSON.
  • Added a validation step intended to throw std::invalid_argument when scrypt parameters are invalid.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 25, 2026

Binary size comparison

➡️ aarch64-apple-ios: 14.34 MB

➡️ aarch64-apple-ios-sim: 14.34 MB

➡️ aarch64-linux-android: 18.77 MB

➡️ armv7-linux-androideabi: 16.20 MB

➡️ wasm32-unknown-emscripten: 13.68 MB

erdemaslan-tw
erdemaslan-tw previously approved these changes Feb 27, 2026
@sergei-boiko-trustwallet sergei-boiko-trustwallet merged commit 8f45b93 into master Mar 6, 2026
15 checks passed
@sergei-boiko-trustwallet sergei-boiko-trustwallet deleted the fix/scrypt-deserialize branch March 6, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants